import { IModalCallBackEvents, IModalEmit } from '@inbiz/render';

export interface IProps {
  callBackEvents?: {
    onParamFormat?: (param: { appId: string; groupKey: string }) => {
      appId: string;
      groupKey: string;
    };
    onRequest?: (parm: any) => Promise<any>;
    onData?: (
      data: {
        Value: string;
        Text: string;
      }[],
    ) => object[];
    onTextParamFormat?: (parm: any) => Promise<any>;
    onTextRequest?: (parm: any) => Promise<any>;
    onTextData?: (parm: any) => Promise<any>;
  } & IModalCallBackEvents;
  emit?: {
    (type: 'onChange', arg: string[] | string | null): void;
    (type: 'onload'): void;
    (type: 'onSuccess', arg: object[]): void;
    (type: 'onError'): void;
    (type: 'onDropdownVisibleChange', arg: boolean): void;
    (type: 'onSelect', arg1: any, arg2: boolean, arg3: any): void;
  } & IModalEmit;
  readOnly?: boolean;
  disabled?: boolean;
  selecttype?: boolean;
  autoLoading?: boolean;
  showconfig?: {
    selectName?: string;
    pageSize?: number;
    list?: {
      YsField: string;
      Value: string;
      Text: string;
      Width: string | number;
      SelectText: string;
      modelName: string;
    }[];
    modelName?: string;
    storageField?: string;
    showHeader?: boolean;
  };
  inbiz?: {
    appInfo?: {
      appId?: string;
    };
  };
  placeholder?: string;
  sourceModel?: string;
  defaulttype?: string;
  default?: string;
  systemDefaultValue?: string;
  dropdownHeight?: number;
  value: any;
  childModelConfig: boolean;
  storageConfig?: {
    business: string;
    tableData: {
      id: number;
      modelAttr: string;
      componentAttr: string;
    }[];
  };
  sourcetype: string;
  primarykey?: string;
  apiPrimaryColumn?: any;
  viewMode?: string;
  onChange: (v: any) => void;
}

export interface Column {
  title: any;
  key: string;
  dataIndex: string;
  width: number;
  ellipsis: {
    showTitle: boolean;
  };
  render: (val: any) => JSX.Element;
}

export interface DynamicListTableProps {
  menu: React.ReactElement<any, string | React.JSXElementConstructor<any>>
  selectType: boolean;
  columns: Column[];
  dataSource: {[key: string]: any}[];
  total: number;
  current: number;
  pageSize: number;
  loadding: boolean;
  storageField: string;
  scroll: {
    x: number;
    y: number
  };
  selectValue: string[] | string | null;
  options: { value: string; label: string }[];
  showField: string;
  memuRef: any;
  selectRef: any;
  $options: React.Dispatch<React.SetStateAction<any[]>>;
  $current: React.Dispatch<React.SetStateAction<number>>;
  $pageSize: React.Dispatch<React.SetStateAction<number>>;
  $searchIpt: React.Dispatch<React.SetStateAction<string>>;
  search: (idx: number, size?: number) => void;
  onChange: (v: any) => void;
}
